import { _brandList } from "../../service/api";
Page({
  data: {
    page: 1,
    size: 10,
    brandList: [],
    total: 0,
  },
  onLoad: function (options) {
    this.initData();
  },
  async initData() {
    const { page, size } = this.data;
    const { data, count } = await _brandList({ page, size });
    this.setData({ brandList: [...this.data.brandList, ...data], total: count });
  },
  onReachBottom() {
    console.log("hello world");
    const { page, total } = this.data;
    if (page < Math.ceil(total / 10)) {
      this.setData({ page: page + 1 });
      this.initData();
    }
  },
});
